home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextLibrary / Frameworks / NIAccess.framework / Versions / A / Headers / NIDomain.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  8.2 KB  |  345 lines

  1. /*
  2.     NIDomain.h
  3.     NetInfo Domain Class
  4.     Copyright (c) 1994, NeXT Computer, Inc.
  5.     All rights reserved.
  6.  */
  7.  
  8. #ifndef STRICT_OPENSTEP
  9.  
  10. #import <Foundation/NSArray.h>
  11. #import <Foundation/NSString.h>
  12. #import <Foundation/NSDate.h>
  13. #import <Foundation/NSDictionary.h>
  14. #import <Foundation/NSLock.h>
  15. #import <Foundation/NSHost.h>
  16. #import <NIAccess/NIServer.h>
  17. @class NIDirectory;
  18.  
  19. @interface NIDomain : NSObject
  20. {
  21.     @private
  22.     NSString *domainName;
  23.     NIDomain *parentDomain;
  24.     NSMutableDictionary *childDict;
  25.     NSMutableArray *childInfo;
  26.     NSMutableArray *childDomains;
  27.     NSMutableArray *childNames;
  28.     NSMutableArray *childIsLocal;
  29.     NSHost *masterHost;
  30.     NIServer *master;
  31.     NSString *masterName;
  32.     NSString *masterHostName;
  33.     NSString *masterTag;
  34.     NSMutableArray *serverInfo;
  35.     NSMutableArray *serverList;
  36.     NSTimeInterval readTimeout;
  37.     NSTimeInterval writeTimeout;
  38.     BOOL writeRequired;
  39.     BOOL authenticatedAsRoot;
  40.     BOOL authenticated;
  41.     NSString *authUser;
  42.     void *handle;
  43.     NSLock *directoryCacheLock;
  44.     NSMutableDictionary *directoryCache;
  45.     BOOL directoryCacheEnabled;
  46.     BOOL isRootDomain;
  47.     BOOL haveCheckedIsRootDomain;
  48.     id reserved;
  49. }
  50.  
  51. /* 
  52.  * Class Methods
  53.  */
  54.  
  55. /*
  56.  * Domain cache management
  57.  * If enabled, only one object representing each domain is created, and
  58.  * a shared instance is returned by all methods that return a domain.
  59.  * Note that this will affect timeout / needwrite settings, as well
  60.  * as forced connections made with connectToMaster: and connectToServer:
  61.  */
  62. + (void)setDomainCacheEnabled:(BOOL)flag;
  63. + (BOOL)isDomainCacheEnabled;
  64. + (void)flushDomainCache;
  65.  
  66. /*
  67.  * Domains
  68.  */
  69. + (NIDomain *)localDomain;
  70. + (NIDomain *)rootDomain;
  71.  
  72. + (NIDomain *)domainWithName:(NSString *)name
  73.     relativeTo:(NIDomain *)relative
  74.     readTimeout:(NSTimeInterval)readTime
  75.     writeTimeout:(NSTimeInterval)writeTime
  76.     writeRequired:(BOOL)mustWrite;
  77.  
  78. + (NIDomain *)domainWithName:(NSString *)name;
  79.  
  80. + (NIDomain *)domainWithName:(NSString *)name
  81.     relativeTo:(NIDomain *)relative;
  82.  
  83. + (NIDomain *)domainWithName:(NSString *)name
  84.     readTimeout:(NSTimeInterval)readTime
  85.     writeTimeout:(NSTimeInterval)writeTime
  86.     writeRequired:(BOOL)mustWrite;
  87.  
  88. + (NIDomain *)domainWithServer:(NIServer *)server
  89.     readTimeout:(NSTimeInterval)readTime
  90.     writeTimeout:(NSTimeInterval)writeTime;
  91.  
  92. + (NIDomain *)domainWithServer:(NIServer *)server;
  93.  
  94. + (BOOL)domainExistsWithName:(NSString *)name;
  95.  
  96. /*
  97.  * Instance methods
  98.  */
  99.  
  100. /*
  101.  * Initialization
  102.  */
  103. - (NIDomain *)initWithName:(NSString *)name
  104.     relativeTo:(NIDomain *)relative
  105.     readTimeout:(NSTimeInterval)readTime
  106.     writeTimeout:(NSTimeInterval)writeTime
  107.     writeRequired:(BOOL)mustWrite;
  108.  
  109. - (NIDomain *)initWithName:(NSString *)name;
  110.  
  111. - (NIDomain *)initWithName:(NSString *)name
  112.     relativeTo:(NIDomain *)relative;
  113.  
  114. - (NIDomain *)initWithName:(NSString *)name
  115.     readTimeout:(NSTimeInterval)readTime
  116.     writeTimeout:(NSTimeInterval)writeTime
  117.     writeRequired:(BOOL)mustWrite;
  118.  
  119. - (NIDomain *)initWithServer:(NIServer *)server
  120.     readTimeout:(NSTimeInterval)readTime
  121.     writeTimeout:(NSTimeInterval)writeTime;
  122.  
  123. - (NIDomain *)initWithHandle:(void *)d
  124.     readTimeout:(NSTimeInterval)readTime
  125.     writeTimeout:(NSTimeInterval)writeTime
  126.     writeRequired:(BOOL)mustWrite;
  127.  
  128. /*
  129.  * Authentication.
  130.  *
  131.  * Note that users are represented by their name, rather than as an
  132.  * NSUserAccount, since NSUserAccount only works for users known to the
  133.  * local system, but NetInfo users may be in a remote domain and therefore
  134.  * unknown locally.
  135.  */
  136. - (BOOL)authenticateAsUserName:(NSString *)userName
  137.     password:(NSString *)pw;
  138. - (void)deauthenticate;
  139.  
  140. /*
  141.  * Get the current user.
  142.  */
  143. - (NSString *)userName;
  144.  
  145. /*
  146.  * Get authentication status.
  147.  */
  148. - (BOOL)isAuthenticatedAsUserName:(NSString *)userName;
  149. - (BOOL)isAuthenticatedAsRoot;
  150.  
  151. /*
  152.  * Check the status of the connection to this domain.
  153.  * Returns YES if any server is alive.
  154.  */
  155. - (BOOL)isAlive;
  156.  
  157. /*
  158.  * Force the connection to switch to the specified server.
  159.  * Note this will affect shared instances (if Domain cacheing is enabled).
  160.  */
  161. - (BOOL)connectToServer:(NIServer *)server;
  162.  
  163. /*
  164.  * Check the status of the master.
  165.  */
  166. - (BOOL)masterIsAlive;
  167.  
  168. /*
  169.  * Force the connection to switch to the domain's master server.
  170.  * Note this will affect shared instances (if Domain cacheing is enabled).
  171.  */
  172. - (BOOL)connectToMaster;
  173.  
  174. /*
  175.  * Determine if the current connection is to the domain's master.
  176.  */
  177. - (BOOL)isConnectedToMaster;
  178.  
  179. /*
  180.  * Servers for this domain.
  181.  */
  182. - (NIServer *)master;
  183. - (NSString *)masterName;
  184. - (NSString *)masterHostName;
  185. - (NSString *)masterTag;
  186. - (NSArray *)servers;
  187. - (NSArray *)clones;
  188. - (NIServer *)currentServer;
  189. - (void)flushServerCache;
  190.  
  191. /*
  192.  * Get the domain's absolute name. (Starts at "/")
  193.  */
  194. - (NSString *)name;
  195.  
  196. /*
  197.  * Get a child's domain's name relative to this domain.
  198.  */
  199. - (NSString *)nameForChild:(NIDomain *)child;
  200.  
  201. /*
  202.  * Get the domain's name relative to it's parent domain.
  203.  * The root domain's relative name is "/".
  204.  */
  205. - (NSString *)relativeName;
  206.  
  207. /*
  208.  * Set the read timeout.  0 means that read operations never time out.
  209.  * Note this will affect shared instances (if Domain cacheing is enabled).
  210.  */
  211. - (void)setReadTimeout:(NSTimeInterval)readTime;
  212.  
  213. /*
  214.  * Get the current read timeout value.
  215.  */
  216. - (NSTimeInterval)readTimeout;
  217.  
  218. /*
  219.  * Set the write timeout.  0 means that write operations never time out.
  220.  * Note this will affect shared instances (if Domain cacheing is enabled).
  221.  */
  222. - (void)setWriteTimeout:(NSTimeInterval)writeTime;
  223.  
  224. /*
  225.  * Get the current write timeout value.
  226.  */
  227. - (NSTimeInterval)writeTimeout;
  228.  
  229. /*
  230.  * Force the connection to lock onto the master if flag is true,
  231.  * or release this requirement if flag is false.
  232.  * Note this will affect shared instances (if Domain cacheing is enabled).
  233.  */
  234. - (BOOL)writeRequired:(BOOL)flag;
  235.  
  236. /*
  237.  * Get the current setting of the writeRequired flag.
  238.  */
  239. - (BOOL)isWriteRequired;
  240.  
  241. /*
  242.  * Open a connection to a relative domain.
  243.  */
  244. - (NIDomain *)relativeDomainNamed:(NSString *)relativeName;
  245. - (BOOL)hasRelativeDomainNamed:(NSString *)relativeName;
  246.  
  247. /*
  248.  * Open a connection to this a domain's parent domain.
  249.  */
  250. - (NIDomain *)parentDomain;
  251. - (BOOL)hasParentDomain;
  252. /* isRootDomain is just !hasParentDomain */
  253. - (BOOL)isRootDomain;
  254.  
  255. /*
  256.  * Open a connection to a domain's child domain with a specific name.
  257.  */
  258. - (NIDomain *)childDomainNamed:(NSString *)name;
  259. - (BOOL)hasChildDomainNamed:(NSString *)name;
  260.  
  261. /*
  262.  * Child domains.
  263.  */
  264. - (BOOL)hasChildren;
  265. - (unsigned)numberOfChildren;
  266. - (NSArray *)childDomains;
  267. - (NSArray *)childDomainsAreLocal;
  268. - (NSArray *)childDomainNames;
  269. - (void)flushChildCache;
  270.  
  271. /*
  272.  * Directory cache management.
  273.  * If enabled, each domain will cache directory objects, so that only one
  274.  * shared instance of each directory will exist.
  275.  */
  276. - (void)setDirectoryCacheEnabled:(BOOL)flag;
  277. - (BOOL)isDirectoryCacheEnabled;
  278. - (void)flushDirectoryCache;
  279.  
  280. /*
  281.  * Get a domain's root directory.
  282.  */
  283. - (NIDirectory *)rootDirectory;
  284.  
  285. /*
  286.  * Get a directory by ID number.
  287.  */
  288. - (NIDirectory *)directoryWithNumber:(unsigned int)number;
  289. - (BOOL)hasDirectoryWithNumber:(unsigned int)number;
  290.  
  291. /*
  292.  * Get a directory with a specified pathname.
  293.  */
  294. - (NIDirectory *)directoryWithPath:(NSString *)path;
  295. - (BOOL)hasDirectoryWithPath:(NSString *)path;
  296.  
  297. /*
  298.  * Get a list of all directory ID numbers.
  299.  */
  300. - (NSArray *)directoryNumbers;
  301.  
  302. /*
  303.  * Utility methods
  304.  */
  305.  
  306. /*
  307.  * Break a string specifying a serves property (name/tag)
  308.  * into it's two components. 
  309.  */
  310. - (BOOL)getName:(NSString **)nameString
  311.     tag:(NSString **)tagString
  312.     fromServes:(NSString *)servesString;
  313.  
  314. /*
  315.  * Get an array of entries for all servers for child domains.
  316.  * The array contains an array for each child server.
  317.  * The child server array contains 4 strings:
  318.  * hostname, address, domain name, and tag.
  319.  * The components can be addressed by NIServerInfoIndex enums:
  320.  * NIServerInfoHostNameIndex, NIServerInfoAddressIndex,
  321.  * NIServerInfoDomainNameIndex, and NIServerInfoTagIndex.
  322.  */
  323. - (NSArray *)childInfo;
  324.  
  325. /*
  326.  * Get netinfo(3) library handle.
  327.  * Use of the handle should be avoided if at all possible.
  328.  * If the handle is used to make netinfo(3) library calls, and the 
  329.  * application is multi-threaded, then the call should be protected using
  330.  * NINetInfo "lock" and "unlock".  For example:
  331.  *
  332.  * ni_status status;
  333.  * NINetInfo *ni = [NINetInfo netinfo];
  334.  * void *handle = [aDomain handle];
  335.  * [ni lock];
  336.  * status = ni_read(handle, ...);
  337.  * [ni unlock];
  338.  *
  339.  */
  340. - (void *)handle;
  341.  
  342. @end
  343.  
  344. #endif STRICT_OPENSTEP
  345.